<?php

$MSG_ERR = 0;

$_sysGetCorrespondentStatusCodeDescription = array(0 => 'Na', 1 => 'Registred', 2 => 'Incident', 3 => 'Paid', 4 => 'Cancelled', 5 => 'Pre-Cancellation');
$_sysGetCorrespondentIncidentCode = array(0 => 'Na', 1 => 'Registred', 2 => 'In process', 3 => 'Processed', 4 => 'Cancelled');
#$__tftTransactionStatusCode = array('7'=>'1','9'=>'4','11'=>'3');
$__tftGetCorrespondentStatusCode = array('2' => '1', '3' => '1', '16' => '1', '8' => '2', '11' => '3', '9' => '4', '18' => '5', '19', '5');
$__tftReceivedCorrespondentStatusCode = array('1' => '2', '2' => '3', '3' => '11', '4' => '18');
$__tftReceivedCorrespondentStatusCodeDescription = array('REG' => '1', 'PRC' => '2', 'PAI' => '3', 'CCL' => '4');

$_ModelPaymentMode = array('BD' => 'D', 'OF' => 'B', 'HD' => 'E');
if ($GetMethodParams[1]['METRIC'] == 'FIXEDSIZE' && count($data['Incident']) != $GetMethodParams[1]['LENGTH']) {
    $Msg_ERROR = 'Dados Invalidos';
} elseif ($GetMethodParams[1]['METRIC'] == 'VARSIZE' && count($data) != $GetMethodParams[1]['LENGTH']) {
    $Msg_ERROR = 'Dados Invalidos';
} else {

# Fields Array
    $FraPosition['CodeTransactionStatus'] = array('FraStatus', array('facturas'));
    $FraPosition['TransactionDate'] = array('FraFechaIngreso', array('facturas'));
    $FraPosition['CodeTransaction'] = array('FraIncReferenciaCo', array('facturas_income'));
    $FraPosition['ReceiveValue'] = array('FraARecibir', array('facturas'));
    $FraPosition['IsoCodeCurrency'] = array('FraMonDPago', array('facturas'));
    $FraPosition['Notes'] = array('FraNotas', array('facturas'));
    $FraPosition['SenderName'] = array('FraCliNombre', array('facturasextjoins'));
    $FraPosition['SenderStreet'] = array('FraCliDomicilio', array('facturasextjoins'));
    $FraPosition['SenderCountry'] = array('FraCLPais', array('facturasextjoins'));
    $FraPosition['Document'] = array('FraCliDNI', array('facturasextjoins'));
    $FraPosition['ReceiverName'] = array('FraBnfNombre', array('facturasextjoins'));
    $FraPosition['ReceiverIdNumber'] = array('FraBnfCedula', array('facturasextjoins'));
    $FraPosition['ReceiverStreet'] = array('FraBnfDireccion', array('facturasextjoins'));
    $FraPosition['ReceiverZipCode'] = array('FraBnfBarrio', array('facturasextjoins'));
    $FraPosition['ReceiverCity'] = array('FraBnfCiudad', array('facturasextjoins'));
    $FraPosition['ReceiverPhone'] = array('FraBnfTelefono', array('facturas'));
    $FraPosition['ReceiverCountry_attr'] = array('FraBnfPais', array('facturas'));
    $FraPosition['PaymentMode'] = array('FraModoPago', array('facturas'));
    $FraPosition['BankName'] = array('FraCbBanco', array('facturasextjoins'));
    $FraPosition['AgencyName'] = array('FraSucursal', array('facturasextjoins'));
    $FraPosition['AccountNumber'] = array('FraCuenta', array('facturasextjoins'));
    $FraPosition['CodeDestination'] = array('FraAgenciaPago', array('facturas'));

    /*
      <CodeIncident>1315793</CodeIncident>
      <CodeTransaction>2</CodeTransaction>
      <TransactionVersion>1</TransactionVersion>
      <CodeIncidentStatus>1</CodeIncidentStatus>
      <IncidentStatusDescription>Registered</IncidentStatusDescription>
      <IncidentDescription>test</IncidentDescription>
      <DateIncident>
      <Year>2010</Year>
      <Month>10</Month>
      <Day>20</Day>
      <Hour>16</Hour>
      <Min>28</Min>
      <Sec>51</Sec>
      </DateIncident>
      <FieldToModify>
      <FieldName>CodeTransactionStatus</FieldName>
      <FieldOldValue>REG</FieldOldValue>
      <FieldNewValue>CCL</FieldNewValue>
      </FieldToModify>
     */


    if ($FraPosition[$data['FieldToModify']['FieldName']][0] == 'FraStatus') {
        $data['FieldToModify']['FieldNewValue'] = $__tftReceivedCorrespondentStatusCode[$__tftReceivedCorrespondentStatusCodeDescription[$data['FieldToModify']['FieldNewValue']]];
    }
}
